package com.sdsy.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sdsy.constant.ResultErrorInfo;
import com.sdsy.dao.EthLoginDao;
import com.sdsy.domain.EthLoginDO;
import com.sdsy.exception.WalletException;
import com.sdsy.service.EthLoginService;
import com.sdsy.util.SysUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (EthLogin)表服务实现类
 *
 * @author yxc
 * @since 2018-10-24 17:08:47
 */
@Service("ethLoginService")
public class EthLoginServiceImpl extends ServiceImpl<EthLoginDao, EthLoginDO> implements EthLoginService {
    @Resource
    private EthLoginDao ethLoginDao;


    @Override
    public EthLoginDO queryByUserNamePassWord(EthLoginDO vo) {
        String userName = vo.getUserName();
        String password = vo.getPassword();
        if (SysUtil.isNull(userName) || SysUtil.isNull(password)) {
            throw new WalletException(ResultErrorInfo.EMPTY_PARAMETER.getCode(), ResultErrorInfo.EMPTY_PARAMETER.getMsg());
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("user_name", userName);
        map.put("password", password);
        EthLoginDO v1 = null;
        List<EthLoginDO> list = ethLoginDao.selectByMap(map);
        if (!SysUtil.isNull(list) && list.size() > 0) {
            v1 = list.get(0);
        }
        return v1;
    }
}